﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Heightmap_Editor.Menu.Screens
{
    class NewMap : MenuScreen
    {
        MenuSpinner sizeX = new MenuSpinner("Width:  ", 2);
        MenuSpinner sizeY = new MenuSpinner("Height: ", 2);
        private MenuWidget resolution;

        public NewMap()
            : base("New Map")
        {
            MenuEntry create = new MenuEntry("Generate Map");
            resolution=new MenuWidget("Resolution: ");

            create.Selected += create_Selected;

            MenuEntries.Add(sizeX);
            MenuEntries.Add(sizeY);
            MenuEntries.Add(create);
            MenuWidgets.Add(resolution);
        }

        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            resolution.Text = "Size: " + sizeX.Selection*64 + "x" + sizeY.Selection*64;

            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
        }

        void create_Selected(object sender, GameStateManagement.PlayerIndexEventArgs e)
        {
            HeightmapEditor.Instance.GenerateNew(sizeX.Selection, sizeY.Selection);
            HeightmapEditor.Instance.MoveEnabling(true);
            ExitScreen();

            foreach (MenuScreen screen in HeightmapEditor.Instance._screenManager.GetScreens())
                screen.ExitScreen();
        }
    }
}
